home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / examples / example08.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  63 lines

  1. /* Demonstration of 3-d plotting */
  2.  
  3. #include <math.h>
  4.       
  5. #define   NPTS   41
  6.  
  7. static int opt[] = {1,   2,   3,   3};
  8.  
  9. static float alt[] = {60.0,20.0,60.0,60.0};
  10.  
  11. static float az[] = {30.0,60.0,120.0,160.0};
  12.  
  13. static char *title[4] =  {
  14.    "\\frPLPLOT Example 8 - Alt=60, Az=30, Opt=1",
  15.    "\\frPLPLOT Example 8 - Alt=20, Az=60, Opt=2",
  16.    "\\frPLPLOT Example 8 - Alt=60, Az=120, Opt=3",
  17.    "\\frPLPLOT Example 8 - Alt=60, Az=160, Opt=3"
  18. };
  19.  
  20. main()
  21. {
  22.    int i, j, k;
  23.  
  24.    float x[NPTS], y[NPTS], z[NPTS][NPTS];
  25.    float xx, yy, r;
  26.    int work[4*NPTS];
  27.  
  28.    for (i=0; i<NPTS; i++)  {
  29.       x[i] = (i-(NPTS/2))/(double)(NPTS/2);
  30.       y[i] = (i-(NPTS/2))/(double)(NPTS/2);
  31.    }
  32.  
  33.    for (i=0; i<NPTS; i++)  {
  34.       xx = x[i];
  35.       for (j=0; j<NPTS; j++)  {
  36.          yy = y[j];
  37.          r = sqrt(xx*xx + yy*yy);
  38.          z[i][j] = exp(-r*r) * cos(2.0*3.141592654*r);
  39.       }
  40.    }
  41.  
  42.    plstar(1,1);
  43.  
  44.    for (k=0; k<4; k++)  {
  45.       pladv(0);
  46.       plvpor(0.0,1.0,0.0,0.9);
  47.       plwind(-1.0,1.0,-0.9,1.1);
  48.  
  49.       plw3d(1.0,1.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,1.0,alt[k],az[k]);
  50.       plbox3("bnstu","x axis",0.0,0,"bnstu","y axis",0.0,0,
  51.              "bcmnstuv","z axis",0.0,0);
  52.       plot3d(x,y,z,work,NPTS,NPTS,NPTS,opt[k]);
  53.       if(k==1 || k==3)
  54.          plside3(x,y,z,NPTS,NPTS,NPTS,opt[k]);
  55.       if(k==2 || k==3)
  56.          plgrid3(0.0);
  57.       plmtex("t",1.0,0.5,0.5,title[k]);
  58.    }
  59.  
  60.    pltext();
  61.    plend();
  62. }
  63.